package com.newbee.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil
{

	public static final int MAX_LENGTH = 5;
	private static final String EMAIL_RXG = "^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$";

	public static String[] fromFormat(String from)
	{

		String[] array = from.split("\\$");

		int length = array[1].length();

		if (length > MAX_LENGTH)
		{
			array[1] = array[1].subSequence(0, 5) + "…";
		}
		return array;

	}

	public static boolean isEmailFormat(String email)
	{
		Pattern pattern = Pattern.compile(EMAIL_RXG);
		Matcher matcher = pattern.matcher(email);
		return matcher.matches();
	}
}
